package com.ce.pms.occupation.service.impl;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import com.ce.pms.base.service.impl.PmsBaseServiceImpl;
import com.ce.pms.common.model.HmEmployeeDomain;
import com.ce.pms.common.model.SysrefcodeDO;
import com.ce.pms.customer.model.ParticipantDO;
import com.ce.pms.customer.service.IClientRHouseService;
import com.ce.pms.exception.BusinessException;
import com.ce.pms.house.model.HouseDomain;
import com.ce.pms.house.service.IHouseService;
import com.ce.pms.occupation.dao.IIdentityValidateDao;
import com.ce.pms.occupation.dao.IThingEntrustDao;
import com.ce.pms.occupation.dao.IThingGivebackDao;
import com.ce.pms.occupation.dao.IThingHandoverDao;
import com.ce.pms.occupation.model.IdentityValidateDO;
import com.ce.pms.occupation.model.ThingEntrustDO;
import com.ce.pms.occupation.model.ThingGivebackDO;
import com.ce.pms.occupation.model.ThingHandoverDO;
import com.ce.pms.occupation.model.ThingHandoverItemDO;
import com.ce.pms.occupation.service.IIdentityValidateService;
import com.ce.pms.occupation.service.IThingHandoverService;
import com.ce.pms.occupation.vo.IdentityValidateVO;
import com.ce.pms.occupation.vo.ThingEntrustQueryConditionVO;
import com.ce.pms.occupation.vo.ThingEntrustVO;
import com.ce.pms.occupation.vo.ThingGivebackVO;
import com.ce.pms.occupation.vo.ThingHandoverItemVO;
import com.ce.pms.occupation.vo.ThingHandoverVO;
import com.ce.pms.system.occupation.model.ThingHandoverCongfigDO;
import com.ce.util.BeanUtil;
import com.sitechasia.webx.core.support.Page;
import com.sitechasia.webx.core.utils.base.PopulateUtil;


/**
 * 物品委托(移交与托管)服务实现类
 */
public class ThingHandoverServiceImpl extends PmsBaseServiceImpl implements IThingHandoverService
{
	private IThingHandoverDao thingHandoverDao;
	private IIdentityValidateService identityValidateService;
	private IThingEntrustDao thingEntrustDao;
	private IThingGivebackDao thingGivebackDao;
	private IHouseService houseService;
	private IClientRHouseService clientRHouseService;
	private IIdentityValidateDao identityValidateDao;


	public void setIdentityValidateDao(IIdentityValidateDao identityValidateDao)
	{
		this.identityValidateDao = identityValidateDao;
	}


	public void setHouseService(IHouseService houseService)
	{
		this.houseService = houseService;
	}


	public void setClientRHouseService(IClientRHouseService clientRHouseService)
	{
		this.clientRHouseService = clientRHouseService;
	}


	public void setThingEntrustDao(IThingEntrustDao thingEntrustDao)
	{
		this.thingEntrustDao = thingEntrustDao;
	}


	public void setThingHandoverDao(IThingHandoverDao thingHandoverDao)
	{
		this.thingHandoverDao = thingHandoverDao;
	}


	public void setIdentityValidateService(IIdentityValidateService identityValidateService)
	{
		this.identityValidateService = identityValidateService;
	}


	public void setThingGivebackDao(IThingGivebackDao thingGivebackDao)
	{
		this.thingGivebackDao = thingGivebackDao;
	}


	/**
	 * 功能描述: 是否允许新增物品移交 <br>
	 * 条件：1、物业预交款费用收取完毕。
	 * @param identityValidateId
	 * @return Create author: 王浩羽 <br>
	 *         Create on:Jan 7, 2009 <br>
	 *         Edit author: <br>
	 *         Edit on: <br>
	 *         Why: <br>
	 */
	private Boolean isAllowAddThingHandover(Long identityValidateId)
	{
		IdentityValidateDO identityValidateDO = identityValidateDao.findById(identityValidateId);
		if(identityValidateDO == null)
		{
			return false;
		}
		return identityValidateDO.getChargeState().equals(SysrefcodeDO.CONSTANTS_DIGITAL_ONE);
	}


	/**
	 * 功能描述: 物品移交 VO 转DO <br>
	 * @param thingHandoverVO
	 * @param thingHandoverDO
	 * @param identityValidateDO
	 * @return Create author: 王浩羽 <br>
	 *         Create on:Jan 7, 2009 <br>
	 *         Edit author: <br>
	 *         Edit on: <br>
	 *         Why: <br>
	 */
	private ThingHandoverDO assembleThingHandoverV2D(ThingHandoverVO thingHandoverVO, ThingHandoverDO thingHandoverDO, IdentityValidateDO identityValidateDO)
	{
		BeanUtil.convertVoAsDo(thingHandoverVO, thingHandoverDO);
//		IdentityValidateDO identityValidateDO = new IdentityValidateDO();
//		identityValidateService.assembleIdentityValidateV2D(thingHandoverVO.getIdentityValidate(), identityValidateDO);
		thingHandoverDO.setIdentityValidate(identityValidateDO);
		HmEmployeeDomain handoverMan = new HmEmployeeDomain(thingHandoverVO.getHandoverManId());
		handoverMan.setEmployeeName(thingHandoverVO.getHandoverManName());
		thingHandoverDO.setHandoverMan(handoverMan);
		Set<ThingHandoverItemDO> thingHandoverItemDOs = thingHandoverDO.getThingHandoverItems();
		Set<ThingHandoverItemVO> thingHandoverItemVOs = thingHandoverVO.getThingHandoverItems();
		thingHandoverItemDOs = assembleThingHandoverItemSetV2D(thingHandoverItemVOs, thingHandoverItemDOs, thingHandoverDO);
//		thingHandoverDO.setThingHandoverItems(thingHandoverItemDOs);
		return thingHandoverDO;
	}


	/**
	 * 功能描述: 物品项目移交列表 VO 转DO <br>
	 * @param thingHandoverItemVOs
	 * @param thingHandoverItemDOs
	 * @param thingHandoverDO
	 * @return Create author: 王浩羽 <br>
	 *         Create on:Jan 7, 2009 <br>
	 *         Edit author: <br>
	 *         Edit on: <br>
	 *         Why: <br>
	 */
	@SuppressWarnings("unchecked")
	private Set<ThingHandoverItemDO> assembleThingHandoverItemSetV2D(Set<ThingHandoverItemVO> thingHandoverItemVOs,
																		Set<ThingHandoverItemDO> thingHandoverItemDOs, ThingHandoverDO thingHandoverDO)
	{
		Map<Long,ThingHandoverItemDO> doMap = new HashMap<Long, ThingHandoverItemDO>();
		for(ThingHandoverItemDO thingHandoverItemDO : thingHandoverItemDOs)
		{
			doMap.put(thingHandoverItemDO.getKeyword(), thingHandoverItemDO);
		}
		for(ThingHandoverItemVO thingHandoverItemVO : thingHandoverItemVOs)
		{
			ThingHandoverItemDO thingHandoverItemDO = doMap.get(thingHandoverItemVO.getKeyword());
			if(thingHandoverItemDO!=null)
			{
				thingHandoverItemDO.setAmount(thingHandoverItemVO.getAmount());
			}else{
				thingHandoverItemDO = assembleThingHandoverItemV2D(thingHandoverItemVO);
				thingHandoverItemDOs.add(thingHandoverItemDO);
			}
			if(thingHandoverItemDO.getThingHandover()==null)
			{
				thingHandoverItemDO.setThingHandover(thingHandoverDO);
			}
		}
		return thingHandoverItemDOs;
	}


	/**
	 * 功能描述: 物品项目移交 VO 转DO <br>
	 * @param thingHandoverItemVO
	 * @return Create author: 王浩羽 <br>
	 *         Create on:Jan 7, 2009 <br>
	 *         Edit author: <br>
	 *         Edit on: <br>
	 *         Why: <br>
	 */
	private ThingHandoverItemDO assembleThingHandoverItemV2D(ThingHandoverItemVO thingHandoverItemVO)
	{
		ThingHandoverItemDO thingHandoverItemDO = new ThingHandoverItemDO();
		BeanUtil.convertVoAsDo(thingHandoverItemVO, thingHandoverItemDO);
		ThingHandoverCongfigDO thingHandoverCongfigDO = new ThingHandoverCongfigDO();
		thingHandoverCongfigDO.setKeyword(thingHandoverItemVO.getThingHandoverCongfigId());
		thingHandoverCongfigDO.setThingHandoverCongfigName(thingHandoverItemVO.getThingHandoverCongfigName());
		thingHandoverCongfigDO.setDescription(thingHandoverItemVO.getThingHandoverCongfigdescription());
		thingHandoverCongfigDO.setSequence(thingHandoverItemVO.getThingHandoverCongfigsequence());
		thingHandoverItemDO.setThingHandoverCongfig(thingHandoverCongfigDO);
		return thingHandoverItemDO;
	}


	/**
	 * 功能描述: 物品移交 DO 转VO <br>
	 * @param thingHandoverDO
	 * @param thingHandoverVO
	 * @return Create author: 王浩羽 <br>
	 *         Create on:Jan 7, 2009 <br>
	 *         Edit author: <br>
	 *         Edit on: <br>
	 *         Why: <br>
	 */
	private ThingHandoverVO assembleThingHandoverD2V(ThingHandoverDO thingHandoverDO, ThingHandoverVO thingHandoverVO)
	{
		String[] ignore = new String[] {"identityValidate", "thingHandoverItems", "handoverMan"};
		PopulateUtil.populate(thingHandoverDO, thingHandoverVO, ignore);
		IdentityValidateVO identityValidateVO = new IdentityValidateVO();
		identityValidateService.assembleIdentityValidateD2V(thingHandoverDO.getIdentityValidate(), identityValidateVO);
		thingHandoverVO.setIdentityValidate(identityValidateVO);
		HmEmployeeDomain handoverMan = thingHandoverDO.getHandoverMan();
		thingHandoverVO.setHandoverManId(handoverMan.getEmployeeId());
		thingHandoverVO.setHandoverManName(handoverMan.getEmployeeName());
		Set<ThingHandoverItemVO> thingHandoverItemVOs = thingHandoverVO.getThingHandoverItems();
		Set<ThingHandoverItemDO> thingHandoverItemDOs = thingHandoverDO.getThingHandoverItems();
		thingHandoverItemVOs = assembleThingHandoverItemSetD2V(thingHandoverItemDOs, thingHandoverItemVOs);
		thingHandoverVO.setThingHandoverItems(thingHandoverItemVOs);
		return thingHandoverVO;
	}


	/**
	 * 功能描述: 物品项目移交列表 DO 转VO <br>
	 * @param thingHandoverItemDOs
	 * @param thingHandoverItemVOs
	 * @return Create author: 王浩羽 <br>
	 *         Create on:Jan 7, 2009 <br>
	 *         Edit author: <br>
	 *         Edit on: <br>
	 *         Why: <br>
	 */
	private Set<ThingHandoverItemVO> assembleThingHandoverItemSetD2V(Set<ThingHandoverItemDO> thingHandoverItemDOs,
																		Set<ThingHandoverItemVO> thingHandoverItemVOs)
	{
		Assert.notNull(thingHandoverItemDOs);
		Assert.notNull(thingHandoverItemVOs);
		for(ThingHandoverItemDO thingHandoverItemDO : thingHandoverItemDOs)
		{
			ThingHandoverItemVO thingHandoverItemVO = assembleThingHandoverItemD2V(thingHandoverItemDO);
			thingHandoverItemVOs.add(thingHandoverItemVO);
		}
		return thingHandoverItemVOs;
	}


	/**
	 * 功能描述: 物品项目移交 DO 转VO <br>
	 * @param thingHandoverItemDO
	 * @return Create author: 王浩羽 <br>
	 *         Create on:Jan 7, 2009 <br>
	 *         Edit author: <br>
	 *         Edit on: <br>
	 *         Why: <br>
	 */
	private ThingHandoverItemVO assembleThingHandoverItemD2V(ThingHandoverItemDO thingHandoverItemDO)
	{
		if(thingHandoverItemDO==null)
		{
			return null;
		}
		ThingHandoverItemVO thingHandoverItemVO = new ThingHandoverItemVO();
		String[] ignore = new String[] {"thingHandoverCongfig", "thingHandover"};
		PopulateUtil.populate(thingHandoverItemDO, thingHandoverItemVO, ignore);
		if(thingHandoverItemDO.getThingHandover() != null)
		{
			thingHandoverItemVO.setThingHandoverId(thingHandoverItemDO.getThingHandover().getKeyword());
		}
		ThingHandoverCongfigDO thingHandoverCongfigDO = thingHandoverItemDO.getThingHandoverCongfig();
		thingHandoverItemVO.setThingHandoverCongfigId(thingHandoverCongfigDO.getKeyword());
		thingHandoverItemVO.setThingHandoverCongfigName(thingHandoverCongfigDO.getThingHandoverCongfigName());
		thingHandoverItemVO.setThingHandoverCongfigdescription(thingHandoverCongfigDO.getDescription());
		thingHandoverItemVO.setThingHandoverCongfigsequence(thingHandoverCongfigDO.getSequence());
		return thingHandoverItemVO;
	}


	public ThingHandoverVO addThingHandover(ThingHandoverVO thingHandoverVO)
	{
		IdentityValidateVO identityValidateVO = thingHandoverVO.getIdentityValidate();
		Assert.notNull(identityValidateVO);
		Long identityValidateId = identityValidateVO.getKeyword();
		Assert.notNull(identityValidateId);
		IdentityValidateDO identityValidateDO = identityValidateDao.findById(identityValidateId);
		Long houseId = identityValidateDO.getHouse().getKeyword();
		if(thingHandoverVO.getHandoverStatus().equals(SysrefcodeDO.CONSTANTS_DIGITAL_ONE))//选择“是”时才进行判断
		{
			if(!isAllowAddThingHandover(identityValidateId))
			{
				throw new BusinessException("occupation:occupation_thingHandover_add_exception", BusinessException.WARNING);
			}
		}
		ThingHandoverDO thingHandoverDO = null;
		if (thingHandoverVO.getKeyword() != null) {
			thingHandoverDO = thingHandoverDao.findById(thingHandoverVO.getKeyword());
		}else{
			thingHandoverDO = new ThingHandoverDO();
		}
		thingHandoverDO = assembleThingHandoverV2D(thingHandoverVO, thingHandoverDO, identityValidateDO);
		thingHandoverDao.saveOrUpdateObject(thingHandoverDO);

		//通知状态改变
		identityValidateService.receiveAddedThingHandover(identityValidateId, thingHandoverDO.getHandoverStatus());

		List<Long> houses = new ArrayList<Long>();
		houses.add(houseId);
		if(thingHandoverVO.getHandoverStatus().equals(SysrefcodeDO.CONSTANTS_DIGITAL_ONE))//已移交
		{
			houseService.notifyHouseStateFinishOccupation(houses);
		}else{
			houseService.notifyHouseStateOccupationInAction(houses);//未移交
		}
		return thingHandoverVO;
	}


	public ThingHandoverVO getHandoverById(Long thingHandoverId)
	{
		ThingHandoverDO thingHandoverDO = thingHandoverDao.findById(thingHandoverId);
		if(thingHandoverDO == null)
		{
			return null;
		}
		ThingHandoverVO thingHandoverVO = new ThingHandoverVO();
		return assembleThingHandoverD2V(thingHandoverDO, thingHandoverVO);
	}


	public ThingEntrustVO addThingEntrust(ThingEntrustVO thingEntrustVO)
	{
		if(!isAllowAddThingEntrust(thingEntrustVO.getHouseId()))
		{
			throw new BusinessException("occupation:occupation_thingEntrust_add_exception",
										BusinessException.WARNING);
		}
		ThingEntrustDO thingEntrustDO = new ThingEntrustDO();
		assembleThingEntrustV2D(thingEntrustVO, thingEntrustDO);
		thingEntrustDao.saveObject(thingEntrustDO);
		return thingEntrustVO;
	}


	public void deleteThingEntrust(Long thingEntrustId)
	{
		if(!isAllowDeleteThingEntrust(thingEntrustId))
		{
			throw new BusinessException("occupation:occupation_thingEntrust_delete_exception",
										BusinessException.WARNING);
		}
		//做逻辑删除
		ThingEntrustDO thingEntrustDO = thingEntrustDao.findById(thingEntrustId);
		thingEntrustDO.setEnableState(SysrefcodeDO.CONSTANTS_DIGITAL_ZERO);//置为无效
		thingEntrustDao.saveOrUpdateObject(thingEntrustDO);
	}


	public ThingEntrustVO editThingEntrust(ThingEntrustVO thingEntrustVO)
	{
		if(!isAllowEditThingEntrust(thingEntrustVO.getKeyword()))
		{
			throw new BusinessException("occupation:occupation_thingEntrust_edit_exception", BusinessException.WARNING);
		}
		ThingEntrustDO thingEntrustDO = new ThingEntrustDO();
		assembleThingEntrustV2D(thingEntrustVO, thingEntrustDO);
		thingEntrustDao.saveOrUpdateObject(thingEntrustDO);
		return thingEntrustVO;
	}


	public ThingEntrustVO getThingEntrustInfo(Long thingEntrustId)
	{
		ThingEntrustDO thingEntrustDO = thingEntrustDao.findById(thingEntrustId);
		if(thingEntrustDO == null)
		{
			return null;
		}
		ThingEntrustVO thingEntrustVO = new ThingEntrustVO();
		assembleThingEntrustD2V(thingEntrustDO, thingEntrustVO);
		return thingEntrustVO;
	}


	public void handleThingGiveback(ThingGivebackVO thingGivebackVO)
	{
		if(!isAllowHandleThingGiveback(thingGivebackVO.getKeyword()))
		{
			throw new BusinessException("occupation:occupation_thingGiveback_handle_exception",
										BusinessException.WARNING);
		}
		ThingGivebackDO thingGivebackDO = new ThingGivebackDO();
		thingGivebackDO = assembleThingGivebackV2D(thingGivebackVO, thingGivebackDO);
		thingGivebackDao.saveOrUpdateObject(thingGivebackDO);
	}


	/**
	 * 功能描述: 物品归还VO 转 DO <br>
	 * @param thingGivebackVO
	 * @param thingGivebackDO
	 * @return Create author: 王浩羽 <br>
	 *         Create on:Jan 9, 2009 <br>
	 *         Edit author: <br>
	 *         Edit on: <br>
	 *         Why: <br>
	 */
	private ThingGivebackDO assembleThingGivebackV2D(ThingGivebackVO thingGivebackVO, ThingGivebackDO thingGivebackDO)
	{
		if(thingGivebackDO == null)
		{
			return null;
		}
		BeanUtil.convertVoAsDo(thingGivebackVO, thingGivebackDO);
		ThingEntrustDO thingEntrustDO = new ThingEntrustDO(thingGivebackVO.getThingEntrustId());
		thingGivebackDO.setThingEntrust(thingEntrustDO);
		return thingGivebackDO;
	}


	public Page queryThingEntrustList(ThingEntrustQueryConditionVO queryCondition)
	{
		queryCondition.checkRule();
		Page page = thingEntrustDao.queryThingEntrustList(queryCondition);
		return page;
	}

	/***
	 * 功能描述: 物品归还VO转DO <br>
	 * @param givebackDO
	 * @param givebackVO
	 * @return
	 * Create author: 王浩羽 <br>
	 * Create on:Jan 14, 2009  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private ThingGivebackVO assembleThingGivebackD2V(ThingGivebackDO givebackDO, ThingGivebackVO givebackVO){
		if(givebackDO==null)
		{
			return null;
		}
		String[] ignore = new String[] {"thingEntrust"};
		PopulateUtil.populate(givebackDO, givebackVO, ignore);
		if(givebackDO.getThingEntrust()!=null)
		{
			givebackVO.setThingEntrustId(givebackDO.getThingEntrust().getKeyword());
		}
		return givebackVO;
	}

	public ThingGivebackVO getThingGivebackByThingEntrustId(Long thingEntrustId){
		ThingGivebackDO thingGivebackDO = thingGivebackDao.getThingGivebackByThingEntrustId(thingEntrustId);
		ThingGivebackVO thingGivebackVO = new ThingGivebackVO();
		thingGivebackVO = assembleThingGivebackD2V(thingGivebackDO, thingGivebackVO);
		return thingGivebackVO;
	}

	/**
	 * 功能描述: 是否容许添加物品托管 <br>
	 * 条件：存在业主
	 * @param houseId
	 * @return Create author: 王浩羽 <br>
	 *         Create on:Jan 8, 2009 <br>
	 *         Edit author: <br>
	 *         Edit on: <br>
	 *         Why: <br>
	 */
	private boolean isAllowAddThingEntrust(Long houseId)
	{
		List<ParticipantDO> owners = clientRHouseService.getAllOwnerByHouseId(houseId);
		if(owners == null || owners.isEmpty())
		{
			return false;
		}
		return true;
	}


	/**
	 * 功能描述: 是否容许修改物品托管 <br>
	 * 条件：物品归还后不能再修改
	 * @param thingEntrustId
	 * @return Create author: 王浩羽 <br>
	 *         Create on:Jan 8, 2009 <br>
	 *         Edit author: <br>
	 *         Edit on: <br>
	 *         Why: <br>
	 */
	public boolean isAllowEditThingEntrust(Long thingEntrustId)
	{
		ThingGivebackDO thingGivebackDO = thingGivebackDao.getThingGivebackByThingEntrustId(thingEntrustId);
		if(thingGivebackDO == null)
		{
			return true;
		}
		// 如果存在归还人，就表示物品已经归还
		return !StringUtils.hasText(thingGivebackDO.getGivebackMan());
	}


	/**
	 * 功能描述: 是否容许删除物品托管 <br>
	 * 注：没有限制条件，删除只做逻辑删除
	 * @param thingEntrustId
	 * @return Create author: 王浩羽 <br>
	 *         Create on:Jan 8, 2009 <br>
	 *         Edit author: <br>
	 *         Edit on: <br>
	 *         Why: <br>
	 */
	public boolean isAllowDeleteThingEntrust(Long thingEntrustId)
	{
		//归还后不能删除，这条件与修改的是一致的
		return isAllowEditThingEntrust(thingEntrustId);
	}


	/**
	 * 功能描述: 是否容许进行物品归还 <br>
	 * 注：业务上暂不做限制
	 * @param thingEntrustId
	 * @return Create author: 王浩羽 <br>
	 *         Create on:Jan 8, 2009 <br>
	 *         Edit author: <br>
	 *         Edit on: <br>
	 *         Why: <br>
	 */
	private boolean isAllowHandleThingGiveback(Long thingEntrustId)
	{
		return true;
	}


	/**
	 * 功能描述: 物品托管 DO 转 VO <br>
	 * @param thingEntrustDO
	 * @param thingEntrustVO
	 * @return Create author: 王浩羽 <br>
	 *         Create on:Jan 8, 2009 <br>
	 *         Edit author: <br>
	 *         Edit on: <br>
	 *         Why: <br>
	 */
	private ThingEntrustVO assembleThingEntrustD2V(ThingEntrustDO thingEntrustDO, ThingEntrustVO thingEntrustVO)
	{
		String[] ignore = new String[] {"house", "accepter"};
		PopulateUtil.populate(thingEntrustDO, thingEntrustVO, ignore);

		HouseDomain house = thingEntrustDO.getHouse();
		if(house != null)
		{
			thingEntrustVO.setHouseId(house.getKeyword());
			thingEntrustVO.setHouseNumber(house.getHouseNumber());
		}
		HmEmployeeDomain accepter = thingEntrustDO.getAccepter();
		if(accepter != null)
		{
			thingEntrustVO.setAccepterId(accepter.getEmployeeId());
			thingEntrustVO.setAccepterName(accepter.getEmployeeName());
		}
		return thingEntrustVO;
	}

	/**
	 * 功能描述: 物品托管 VO 转 DO <br>
	 * @param thingEntrustVO
	 * @param thingEntrustDO
	 * @return Create author: 王浩羽 <br>
	 *         Create on:Jan 8, 2009 <br>
	 *         Edit author: <br>
	 *         Edit on: <br>
	 *         Why: <br>
	 */
	private ThingEntrustDO assembleThingEntrustV2D(ThingEntrustVO thingEntrustVO, ThingEntrustDO thingEntrustDO)
	{
		BeanUtil.convertVoAsDo(thingEntrustVO, thingEntrustDO);
		HouseDomain house = new HouseDomain(thingEntrustVO.getHouseId());
		thingEntrustDO.setHouse(house);
		HmEmployeeDomain accepter = new HmEmployeeDomain(thingEntrustVO.getAccepterId());
		thingEntrustDO.setAccepter(accepter);
		return thingEntrustDO;
	}


	/**
	 * 功能描述: 通知物品委托 <br>
	 * @param identityValidateId
	 *        Create author: 王浩羽 <br>
	 *        Create on:Jan 8, 2009 <br>
	 *        Edit author: <br>
	 *        Edit on: <br>
	 *        Why: <br>
	 */
	private void notifyHandleThingEntrust(Long identityValidateId)
	{

	}


	public ThingHandoverVO getHandoverByIndentityId(Long identityId)
	{
		ThingHandoverDO thingHandoverDO = thingHandoverDao.getHandoverByIndentityId(identityId);
		if(thingHandoverDO == null)
		{
			return null;
		}
		ThingHandoverVO thingHandoverVO = new ThingHandoverVO();
		assembleThingHandoverD2V(thingHandoverDO, thingHandoverVO);
		return thingHandoverVO;
	}

}
